package com.jiaai.cloud;


import com.jiaai.cloud.base.redis.util.RedisUtil;
import com.jiaai.cloud.base.util.IdWorkUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan("com.jiaai.cloud.**.mapper")
public class  ApiServerApplication {
	public static void main(String[] args) {
		SpringApplication.run(ApiServerApplication.class, args);
	}

	/**
	 * 配制id生成器
	 * @param redisUtil
	 * @return
	 */
	@Bean
	@ConditionalOnMissingBean(IdWorkUtil.class)//容器中如果没有RedisClient这个类,那么自动配置这个RedisClient
	public IdWorkUtil idWorkUtil(@Qualifier("rdisUtil")RedisUtil redisUtil) {
		IdWorkUtil workUtil=new IdWorkUtil(redisUtil,23);
		return workUtil;
	}
}
